use Dosvid
go

if exists(select 1
		  from sysobjects
		  where name = 'Vacancy_CommodityGroups')
  drop table Vacancy_CommodityGroups
go

create table Vacancy_CommodityGroups
(
  Id int identity(1,1) not null,
  VacancyId int not null,
  CommodityGroupId int not null
)  
go

alter table Vacancy_CommodityGroups add constraint PK_Vacancy_CommodityGroups_ID primary key(Id) 
go


alter table Vacancy_CommodityGroups add constraint FK_Vacancy_CommodityGroups_CommodityGroups_CommodityGroupId 
      foreign key (CommodityGroupId) references CommodityGroups(Id) on delete cascade
go


alter table Vacancy_CommodityGroups add constraint FK_Vacancy_CommodityGroups_CommodityGroups_VacancyId 
      foreign key (VacancyId) references Vacancies(Id) on delete cascade
go


create nonclustered index IX_Vacancy_CommodityGroups_VacancyId on Vacancy_CommodityGroups
       (VacancyId asc)
go
